<template>
	<view class="content">
		<view class="input_list">
			<view class="title_list"><view class="line"></view>充值金额</view>
			<view class="input_box">
				<text style="font-size: 44rpx; margin-top: -25rpx; margin-right: 10rpx;">￥</text>
				<input type="number"  placeholder="请输入充值金额" placeholder-class="input_class" v-model='money'/>
			</view>
		</view>
		<view class="list_box">
			<view class="title_list"><view class="line"></view>支付信息</view>
			<view class="list_item">
				<image class="list_icon" src="../../static/image/ico_wx@2x.png" mode=""></image>
				<view class="list_item_right">
					<view class="list_title">微信支付</view>
					<image src="../../static/image/ddjs_ico_xz_nor@2x.png" mode="" v-show="type!=1"  @click="chooseType(1)"></image>
					<image src="../../static/image/ddjs_ico_xz_sel@2x.png" mode="" v-show="type==1" ></image>
				</view>
			</view>
			<view class="list_item">
				<image class="list_icon1" src="../../static/image/ico_zfb@2x.png" mode=""></image>
				<view class="list_item_right">
					<view class="list_title">支付宝支付</view>
					<image src="../../static/image/ddjs_ico_xz_sel@2x.png" mode="" v-show="type==2"></image>
					<image src="../../static/image/ddjs_ico_xz_nor@2x.png" mode="" v-show="type!=2" @click="chooseType(2)"></image>
					
				</view>
			</view>
		</view>
		<view class="btn" @click='entruepay'>确认</view>
	</view>
</template>

<script>
	import {recharge} from '@/api/personal.js'
	export default {
		data() {
			return {
				type:1,
				money:''
			}
		},
		onLoad() {

		},
		methods: {
			chooseType(val){
				this.type=val
			},
			entruepay(){
				// wx
				let pro = ''
				this.type==1?pro = 'wxpay':pro = 'alipay'
					let obj = {
						pay_type:this.type,
						money:this.money
					}
					recharge(obj).then(res=>{
							this.$msg(res.msg)
							console.log(res.data,'444')
							uni.requestPayment({
									provider: pro,
							        orderInfo: JSON.stringify(res.data), 
							        success: function (res) {
							            console.log('success:' + JSON.stringify(res));
										uni.navigateBack({
											delta:1
										})
							        },
							        fail: function (err) {
							            console.log('fail:' + JSON.stringify(err));
							        }
							    });
					})
			},
		}
	}
</script>

<style>
	.content {
		width: 100%;
		height: 100%;
		overflow: hidden;
		background-color: #F5F5F5;
	}
	.title_list{
		width: 100%;
		height: 88rpx;
		padding: 0 30rpx;
		display: flex;
		align-items: center;
		font-size: 34rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #333333;
	}
	.input_list{
		width: 100%;
		height: 200rpx;
		background-color: #FFFFFF;
		margin-top: 20rpx;
		/* display: flex;
		align-items: center; */
	}
	.input_box{
		width: 86%;
		height: 100rpx;
		margin: 0 auto;
		display: flex;
		justify-content: flex-start;
		align-items: center;
		/* border-bottom: 1rpx solid #F5F5F5; */
	}
	.input_class{
		font-size: 28rpx;
		color: #999999;
	}
	.list_box{
		width: 100%;
		height: auto;
		display: flex;
		justify-content: flex-start;
		align-items: center;
		flex-direction: column;
		background-color: #FFFFFF;
		margin-top: 20rpx;
	}
	.list_item{
		width: 96%;
		height: 100rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		border-bottom: 1rpx solid #F5F5F5;
		margin-left: 30rpx;
	}
	.list_icon{
		width: 40rpx;
		height: 35rpx;
		margin-right: 20rpx;
	}
	.list_icon1{
		width: 40rpx;
		height: 40rpx;
		margin-right: 20rpx;
	}
	.list_icon2{
		width: 42rpx;
		height: 44rpx;
		margin-right: 20rpx;
	}
	.list_title{
		font-size: 28rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #333333;
	}
	.list_item_right{
		height: 100%;
		width: 90%;
		display: flex;
		justify-content: space-between;
		align-items: center;
		
	}
	.list_item_right image{
	    width: 36rpx;
	    height: 36rpx;
		margin-right: 20rpx;
	}
	.list_title{
		font-size: 28rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #333333;
	}
	.btn{
		width: 86%;
		height: 88rpx;
		background: #FFDD47;
		border-radius: 10rpx;
		margin: 0 auto;
		display: flex;
		justify-content: center;
		align-items: center;
		margin-top: 80rpx;
		font-size: 30rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #333333;
		position: absolute;
		bottom: 3%;
		left: 6.7%;
	}
	.line{
		width: 4rpx;
		height: 20rpx;
		background: #FFDD47;
		border-radius: 2rpx;
		margin-right: 6rpx;
	}

	
</style>
